﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using OnlineGameLibrary.MessageEx;

namespace OnlineGameLibrary.Contract
{
    public class GameRoomMessageDefines
    {
        //public static readonly MessageDefine ROOM_UPDATE;
        public static readonly MessageDefine ROOM_GAMESTART;

        public static readonly MessageDefine ROOM_PLAYER_LEAVE;
        public static readonly MessageDefine ROOM_PLAYER_JOIN;
        public static readonly MessageDefine ROOM_PLAYER_UPDATE;

        public static readonly MessageDefine ROOM_CONFIG_UPDATE;

        public static readonly MessageDefine ROOM_UPDATE;
        public static readonly MessageDefine ROOM_NEW;
        public static readonly MessageDefine ROOM_DELETE;

        public static string Namespace = "http://gameroom";
        static List<MessageDefine> _msgdefines;
        static GameRoomMessageDefines()
        {
            _msgdefines = new List<MessageDefine>();

            //ROOM_UPDATE = new MessageDefine(Namespace, "ROOM_UPDATE", typeof(RoomUpdateMessage));
            //_msgdefines.Add(ROOM_UPDATE);

            ROOM_GAMESTART = new MessageDefine(Namespace, "ROOM_GAMESTART", typeof(DateTime));
            _msgdefines.Add(ROOM_GAMESTART);

            ROOM_PLAYER_LEAVE = new MessageDefine(Namespace, "ROOM_PLAYER_LEAVE", typeof(Player));
            _msgdefines.Add(ROOM_PLAYER_LEAVE);

            ROOM_PLAYER_JOIN = new MessageDefine(Namespace, "ROOM_PLAYER_JOIN", typeof(Player));
            _msgdefines.Add(ROOM_PLAYER_JOIN);

            ROOM_PLAYER_UPDATE = new MessageDefine(Namespace, "ROOM_PLAYER_UPDATE", typeof(Player));
            _msgdefines.Add(ROOM_PLAYER_UPDATE);

            ROOM_CONFIG_UPDATE = new MessageDefine(Namespace, "ROOM_CONFIG_UPDATE", typeof(GameConfig));
            _msgdefines.Add(ROOM_CONFIG_UPDATE);

            // all players scope

            ROOM_UPDATE = new MessageDefine(Namespace, "ROOM_UPDATE", typeof(GameRoom));
            _msgdefines.Add(ROOM_UPDATE);

            ROOM_NEW = new MessageDefine(Namespace, "ROOM_NEW", typeof(GameRoom));
            _msgdefines.Add(ROOM_NEW);

            ROOM_DELETE = new MessageDefine(Namespace, "ROOM_DELETE", typeof(Guid));
            _msgdefines.Add(ROOM_DELETE);
        }
    }

    [DataContract(Namespace = "http://gameroom/messagecontract")]
    public class RoomUpdateMessage
    {
        [DataMember]
        public GameRoomField UpdateField { set; get; }
    }

    [DataContract(Namespace = "http://gameroom/messagecontract")]
    public enum GameRoomField
    {
        [EnumMember]
        Player,
        [EnumMember]
        Config,
    }
}
